import socket
import time

# import ser_read
# 创建 socket 对象
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 获取本地主机名
host = '169.254.109.174'

# 设置服务器端的端口
port = 62021

# ser_read.ser_read_demo2()
# 连接服务器
client_socket.connect((host, port))

try:
    while 1:
        # 发送数据到服务器
        # message = "stop"
        # client_socket.connect((host, port))
        # message='test'
        # client_socket.send(message.encode())

        # 接收服务器的响应
        received_message = client_socket.recv(20).decode()

        print(f"time：{time.time()-float(received_message)}")
        time.sleep(1)

# ser_read.ser_read_demo2()
# 关闭客户端
except Exception as e:
    print(e)
    client_socket.close()